package cn.onlineclass.keyun.vo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author oldliu
 * @since 1.0
 */
//分页类
public class Page<T> implements Serializable {
    public static final int PAGE_SIZE=10;//默认是10条
    //本页的数据
    private List<T> data=new ArrayList<>(0);
    //
    private int pageNo=1;//当前页数
    private int total;//总个数
    private int pageSize=PAGE_SIZE;
    //private int totalPages;
    public Page(){

    }

    public Page(List<T> data, int pageNo, int total) {
        this.data = data;
        this.pageNo = pageNo;
        this.total = total;
    }

    public Page(int pageNo, int total) {
        this.pageNo = pageNo;
        this.total = total;
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public int getPageNo() {
        return pageNo;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }
    //获得页数
    public int getTotalPages(){
        return this.total/this.pageSize+(this.total%this.pageSize==0?0:1);
    }
    @Override
    public String toString() {
        return "Page{" +
                "data=" + data +
                ", pageNo=" + pageNo +
                ", total=" + total +
                ", pageSize=" + pageSize +
                '}';
    }
}
